	<div class="box box-left">
		<div class="title">
			<h5><?php echo $this->__('Attribute Group List');?></h5>
			<ul class="links">
				<li><a href="<?php echo App::Config()->baseUrl("/managestore/productattributes/addgroup");?>">Create New Group >></a></li>
			</ul>			
		</div>
		<div class="form">
		<?php if(!empty($groupList['data'])):?>
			<?php
				$Grid = App::Module('DataGrid')->setHeader(array("ATTRIBUTE GROUP NAME","#"));
				foreach($groupList['data'] as $row){
					$Grid->addRow(
						$row['name'],
						App::Html()->LinkTag(App::Config()->baseUrl("/managestore/productattributes/edit/{$row['id']}"),'Change')
					);
				}
				$Grid->Render();
			?>			
		<?php endif;?>
			<a href="<?php echo App::Config()->baseUrl("/managestore/productattributes/addgroup");?>">
				<h3 class="first"><?php echo $this->__("Click here to add new Group");?></h3>
			</a>		
		</div>
	</div>
	
	<?php $attributeGroup = App::Component('appStore')->Helper('Common')->getAttributeGroupById($id);?>
	<div class="box box-right">
		<div class="title">
			<h5><?php echo isset($attributeGroup['name']) ? $attributeGroup['name'] : $this->__('Manage Fields');?></h5>
			<ul class="links">
				<li><a href="<?php echo App::Config()->baseUrl("/managestore/productattributes/addfield/{$id}");?>">Add New Field >></a></li>
			</ul>			
		</div>		
		<div class="form">
			<div class="fields">
			<?php if(in_array($action,array('edit'))):?>
				<form action="<?php echo App::Config()->baseUrl("/managestore/productattributes/editgroup/{$id}"); ?>" method="post">
					<div class="buttons">
						<?php echo App::load("Helper/Html")->inputTag("data[AttributeGroup][name]",$attributeGroup['name'], array("id" => "name", "longdesc"=>"Please enter group name", "class" => "check_notempty app_input small"));?> <input type="submit" name="submit" value="Save"/>
					</div>				
				</form>	
				<br />
			<?php endif;?>
			<?php if(isset($attributeGroup['object']) && !empty($attributeGroup['object'])): ?>
				<?php
					$Grid = App::Module('DataGrid')->Clear()->setHeader(array("Title","Type","Key","#"));
					foreach($attributeGroup['object'] as $key=>$field){
						$AId = isset($field['key']) ? $field['key'] : '<span style="color:red">Format Error</span>';
						$Grid->addRow(
							$field['title'],
							$field['type'],
							$AId,
							App::Html()->LinkTag(App::Config()->baseUrl("/managestore/productattributes/editattribute/{$id}?seq={$key}"),'Edit') . ' &nbsp; | &nbsp;' . 
							App::Html()->LinkTag(App::Config()->baseUrl("/managestore/productattributes/deleteattribute/{$id}?seq={$key}"),'Delete',array('class'=>'confirm-link'))
						);
					}
					$Grid->Render();
				?>				
			<?php endif;?>							
			<?php if(in_array($action,array('addgroup'))):?>
				<form action="<?php echo App::Config()->baseUrl("/managestore/productattributes/{$action}"); ?>" method="post">
					<div class="field">
						<div class="label">
							<label for="name"><?php echo $this->__("Enter Group Name");?><label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->inputTag("data[AttributeGroup][name]",'', array("id" => "name", "longdesc"=>"Please enter group name", "class" => "check_notempty app_input"));?>
						</div>
					</div>				
					<div class="buttons">
						<input type="submit" name="submit" value="Create Group"/>
					</div>				
				</form>		
			<?php elseif(in_array($action,array('addfield','editattribute')) ):?>
					<?php 
						$seq = isset($this->get['seq']) ? $this->get['seq'] : '';
						$title = '';$type='';$validation='';$optvalues='';$defaultvalue='';$comments='';
						if(!empty($attributeGroup['object'])){
							$title = isset($attributeGroup['object'][$seq]['title']) ? $attributeGroup['object'][$seq]['title'] : '';
							$type = isset($attributeGroup['object'][$seq]['type']) ? $attributeGroup['object'][$seq]['type'] : 'TextBox';
							$validation = isset($attributeGroup['object'][$seq]['validation']) ? $attributeGroup['object'][$seq]['validation'] : 'None';
							$optvalues = isset($attributeGroup['object'][$seq]['optvalues']) ? $attributeGroup['object'][$seq]['optvalues'] : '';
							$defaultvalue = isset($attributeGroup['object'][$seq]['defaultvalue']) ? $attributeGroup['object'][$seq]['defaultvalue'] : '';
							$comments = isset($attributeGroup['object'][$seq]['comments']) ? $attributeGroup['object'][$seq]['comments'] : '';
						}
					?>
					
				<form action="<?php echo App::Config()->baseUrl("/managestore/productattributes/{$action}/{$id}"); ?><?php echo isset($this->get['seq']) ? "?seq={$this->get['seq']}" : ''; ?>" method="post">	
					<div class="field">
						<div class="label">
							<label for="title"><?php echo $this->__("Field Title");?><label>
						</div>
						<div class="input">
							<?php 
								echo App::load("Helper/Html")
									->inputTag("data[Field][title]",$title, array("id" => "title", "longdesc"=>"Please enter a title", "class" => "check_notempty app_input"));?>
						</div>
					</div>	
					<div class="field">
						<div class="label">
							<label for="type"><?php echo $this->__("Field Type");?><label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->selectTag("data[Field][type]",array("TextBox"=>"TextBox","TextArea"=>"TextArea","DropDown"=>"DropDown","CheckBox"=>"CheckBox","RadioButton"=>"RadioButton","colorInput"=>"ColorInput","image"=>"Image"),$type, array("id" => "type", "longdesc"=>"Please select a type", "class" => "check_notempty"),array('off_blank'=>'Yes'));?>
						</div>
					</div>	
					<div class="field">
						<div class="label">
							<label for="type"><?php echo $this->__("Validation Type");?><label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->selectTag("data[Field][validation]",array("Empty"=>"Empty","Email"=>"Email","None"=>"None"),$validation, array("id" => "validation", "longdesc"=>"Please select a type", "class" => "check_notempty"),array('off_blank'=>'Yes'));?>
						</div>
					</div>						
					<div class="field <?php if(!in_array($type,array('DropDown','RadioButton'))):?> displaynone<?php endif;?>" id="optionsblock">
						<div class="label">
							<label for="optvalues"><?php echo $this->__("Option Values");?><label>
						</div>
						<div class="input">
							<p>Saperate value by comma(,). For example: Medimu, XL, Large</p>
							<?php echo App::load("Helper/Html")->inputTag("data[Field][optvalues]",$optvalues, array("id" => "optvalues", "longdesc"=>"Please enter a option values", "class" => "check_notempty app_input"));?>
						</div>
					</div>	
					<div class="field">
						<div class="label">
							<label for="optvalues"><?php echo $this->__("Default Value");?><label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->inputTag("data[Field][defaultvalue]",$defaultvalue, array("id" => "defaultvalue", "class" => "app_input"));?>
						</div>
					</div>							
					<div class="field">
						<div class="label">
							<label for="optvalues"><?php echo $this->__("Comments");?><label>
						</div>
						<div class="input">
							<?php echo App::load("Helper/Html")->textareaTag("data[Field][comments]",$comments, array("id" => "optvalues", "longdesc"=>"Please enter a comment", "class" => "app_input"));?>
						</div>
					</div>					
					<div class="buttons">
						<input type="submit" name="submit" value="Save Field"/>
					</div>				
				</form>	
			<?php else:?>
				<h3 class="first"><a href="<?php echo App::Config()->baseUrl("/managestore/productattributes/addfield/{$id}");?>">Add New Field >></a></h3>
			<?php endif;?>
			</div>
		</div>
	</div>
	<?php  App::Helper('JavaScript')->appForm('form');?>
	<script type="text/javascript">
		jQuery(document).ready(function () {
			jQuery("#type").change(function(event) {
				var arr = ["DropDown","RadioButton","CheckBox"];
				if(
					jQuery.inArray(jQuery(this).val(), arr)	>= 0	
				
				){ 
					jQuery('#optionsblock').show();
				}
				else {
					jQuery('#optionsblock').hide();
				}
			});
		});				
	</script>
